﻿@model Data.DBModels.Website

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Website</legend>

        @Html.HiddenFor(model => model.Id)


        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Url)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Url)
            @Html.ValidationMessageFor(model => model.Url)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
            <div>Categories:</div>
        </div>


        <div>
            @Html.Action("CreateCategoriesDDL", "Category")
            <input type="button" id="btn_selectCategory" value="Select" />
        </div>


        @if (Model.Categories != null)
{
    <ul id="ul_selectedCategories">

        @foreach (Data.DBModels.Category cat in Model.Categories)
{
    <li>
        <input type="hidden" class="selectedCategories"  name="selectedCategories" value="@cat.Id" />
        <div>@cat.Name</div>
        <input type="button" class="deleteCategoryBtn" value="Delete" />
    </li>
}
    </ul>

}
     

        <div class="editor-label">
            @Html.LabelFor(model => model.Ranking)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Ranking)
            @Html.ValidationMessageFor(model => model.Ranking)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
